<?php

namespace App\Admin\Controllers;

use App\Models\GoldRound;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\ConfigStorm;

class ConfigStormsController extends AdminController
{
    protected $title = '支付配置';

    protected function form()
    {
        $form = new Form(new ConfigStorm());


          $form->radio('is_alipay_open', '支付宝支付开关')->options(config('site.bool'))->default(false);

         $form->radio('is_wxpay_open', '微信支付开关')->options(config('site.bool'))->default(false);
        /*$form->radio('is_overcome_pay_fine', '关单是否罚豆')->options(config('site.bool'))->default(false);

	    $form->divider();

        $form->number('take_back_gold_product_within_minutes', '机器回购开始/分钟')->default(10)->min(3)->max(45)->rules('required|min:0');
        $form->number('terminate_gold_product_within_minutes', '机器终结开始/分钟')->default(3)->min(3)->max(45)->rules('required|min:0');

	    $form->divider();

	    $form->radio('is_robot_on', '允许机器人启动')->options(config('site.bool'))->default(true);
	    $form->radio('is_reclaim_on', '允许机器人回收')->options(config('site.bool'))->default(true);
	    $form->radio('is_terminate_on', '允许机器人终结')->options(config('site.bool'))->default(true);*/

	    $this->formTools($form);
	    $this->formFooter($form);
	    $this->formSaved($form);

        return $form;
    }

	protected function formTools(Form $form)
	{
		$form->tools(function (Form\Tools $tools) {
			$tools->disableList();
			$tools->disableView();
			$tools->disableDelete();
		});
	}

	protected function formFooter(Form $form)
	{
		$form->footer(function (Form\Footer $footer) {
			$footer->disableReset();
			$footer->disableViewCheck();
			$footer->disableCreatingCheck();
			$footer->disableEditingCheck();
		});
	}

	protected function formSaved(Form $form)
	{
		$form->saved(function () {
			admin_toastr('会员促销配置', 'success');
			return redirect(route('admin.config-storms.edit', 1));
		});
	}
}
